<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
    <base href="${pageContext.request.contextPath}/"/>
    <title>襄阳蓝芯智能化办公系统</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
        /*定义类名为.thead-blue的样式*/
        .thead-blue {
            color: #fff;
            font-weight: bold;
            background-color: #337ab7;
        }
    </style>
    <link rel="stylesheet" type="text/css" href="view/bootstrap-3.3.5/css/bootstrap.css"/>
    <link rel="stylesheet" type="text/css" href="view/bootstrapvalidator/css/bootstrapValidator.css"/>
    <script charset="utf-8" src="view/jquery/jquery-1.10.2.min.js"></script>
    <script charset="utf-8" src="view/bootstrap-3.3.5/js/bootstrap.js"></script>
    <script charset="utf-8" src="view/bootstrapvalidator/js/bootstrapValidator.js"></script>
</head>
<body>
<!-- 搜索 -->
<div class="panel panel-primary">
    <div class="panel-heading">
        <h4 class="panel-title">领款登记单</h4>
    </div>
    <div class="panel-body">
        <form action="apply/selectregister" id="seachform" method="post" class="form-horizontal" role="form">
            <div class="form-group">
                <div class="col-md-5">
                    <label for="docNo" class="col-md-4 control-label">申请单号</label>
                    <div class="col-md-8">
                        <input type="text" id="docNo" name="docNo" class="form-control"
                               placeholder="请输入申请单号" value="${bxInformal.docNo}">
                        <input type="hidden" name="page" id="page" value="${pageBean.page }">
                        <input type="hidden" name="pageSize" id="pageSize" value="${pageBean.pageSize }">
                    </div>
                </div>
                <div class="col-md-5">
                    <label for="proposer" class="col-md-4 control-label">申请人</label>
                    <div class="col-md-8">
                        <input type="hidden" id="proposer" name="proposer" value="${bxInformal.proposer}">
                        <div class="input-group">
                            <input type="text" id="empName" name="empName"
                                   readonly="readonly" class="form-control" placeholder="请选择申请人"
                                   value="${empName}">
                            <span class="input-group-btn">
									<button class="btn btn-info" type="button" data-toggle="modal"
                                            data-target="#selectempModal">请选择</button>
								</span>
                        </div>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <div class="col-md-5">
                    <label for="status" class="col-md-4 control-label">申请单状态</label>
                    <div class="col-md-8">
                        <select name="status" id="status" class="form-control">
                            <option value="">--申请单状态--</option>
                            <option value="W">--未提交--</option>
                            <option value="S">--审批中--</option>
                            <option value="Y">--审批通过--</option>
                            <option value="N">--审批不通过--</option>
                            <option value="O">--已领款--</option>
                        </select>
                    </div>
                </div>

                <div class="col-md-5">
                    <label for="submitDate" class="col-md-4 control-label">提交时间</label>
                    <div class="col-md-8">
                        <input type="date" id="submitDate" name="submitDate"
                               class="form-control"
                               value="<fmt:formatDate value="${bxInformal.submitDate}" pattern='yyyy-MM-dd'></fmt:formatDate>">
                    </div>
                </div>

                <div class="col-md-2">
                    <label class="col-md-4 control-label"></label>
                    <div class="col-md-8">
                        <button type="button" onclick="searchBtn()" class="btn btn-success">搜索报销申请</button>
                    </div>
                </div>
            </div>

        </form>
    </div>
</div>

<!-- 列表 -->
<div class="panel panel-primary">
    <table class="table table-bordered table-hover">
        <thead>
        <tr class="thead-blue" align="center">
            <td>申请单编号</td>
            <td>申请单创建人</td>
            <td>申请单申请人</td>
            <td>创建时间</td>
            <td>提交时间</td>
            <td>申请单状态</td>
            <td>操作</td>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${pageBean.data}" var="d">
            <tr align="center">
                <td>${d.docNo}</td>
                <td>${d.empcreator.empName}</td>
                <td>${d.empproposer.empName}</td>
                <td>${d.createDate}</td>
                <td>${d.submitDate }</td>
                <td>
                    <c:if test='${d.status=="W" }'>
                        未提交
                    </c:if>
                    <c:if test='${d.status=="S" }'>
                        审批中
                    </c:if>
                    <c:if test='${d.status=="Y" }'>
                        审批通过
                    </c:if>
                    <c:if test='${d.status=="N" }'>
                        审批不通过
                    </c:if>
                    <c:if test='${d.status=="O" }'>
                        已领款
                    </c:if>
                </td>
                <td>
                    <a type="button" href="apply/register?oid=${d.oid}" class="btn btn-info btn-xs">领款登记</a>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
</div>

<!-- 分页 -->
<div class="input-group col-md-6 col-md-offset-3">
    <div class="row">
        <div class="btn-group">
            <button onclick="gotoPage(1,5)"
                    class="btn btn-primary" type="button">首页
            </button>

            <button class="btn btn-primary disabled" type="button">上一页</button>


            <button class="btn btn-primary disabled" type="button">当前第1/1页</button>

            <div class="btn-group">
                <button type="button" class="btn btn-primary dropdown-toggle"
                        data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    每页显示5条 <span class="caret"></span>
                </button>
                <ul class="dropdown-menu">
                    <li><a href="javascript:gotoPage(1,5)">每页显示5条</a></li>
                    <li><a href="javascript:gotoPage(1,10)">每页显示10条</a></li>
                    <li><a href="javascript:gotoPage(1,15)">每页显示15条</a></li>
                    <li><a href="javascript:gotoPage(1,20)">每页显示20条</a></li>
                </ul>
            </div>

            <button class="btn btn-primary disabled" type="button">共4条记录</button>


            <button class="btn btn-primary disabled" type="button">下一页</button>


            <button
                    onclick="gotoPage(1,5)"
                    class="btn btn-primary" type="button">尾页
            </button>
        </div>
    </div>
</div>

<br>
<br>
<br>
<%@include file="../modal/selectemp.jsp" %>
<%@include file="../modal/confirm.jsp" %>

<script>
    $(document).ready(function () {
        $("#subconfirm").click(function () {
            deleteConfirm();
            $('#confirmModal').modal('hide');
        });

        $("#status option[value='${bxInformal.status}']").attr("selected", 'selected');
    });
</script>

<script type="text/javascript">
    $(document).ajaxError(function (event, xhr) {
        if (xhr.status == "403") {//没有权限
            document.location.href = xhr.getResponseHeader("url");
        } else if (xhr.status != "200") {
            //alert("服务器错误!");
            console.log("服务器错误!");
        }
    });
</script>

<script type="text/javascript">
    function setempvalue(eid, empName) {
        $("#proposer").val(eid);
        $("#empName").val(empName);
    }
</script>

</body>
<script type="text/javascript">
    function gotoPage(page, pageSize) {
        $("#page").val(page);
        $("#pageSize").val(pageSize);
        $("#seachform").submit();
    }

    function searchBtn() {
        $("#page").val(1);
        $("#seachform").submit();
    }
</script>
</html>